package com.dlxj.action;

import java.util.Date;

import com.dlxj.entity.Debugtask;
import com.dlxj.entity.DebugtaskUser;
import com.dlxj.service.DeBugTaskService;
import com.dlxj.util.MyJSON;
import com.dlxj.util.PageBean;

public class DeBugAction {

	String json;
	Debugtask debugtask;
	DeBugTaskService deBugTaskService;
	String dps; // 杆塔和巡检任务编号集合
	String uid;
	String did;
	DebugtaskUser debugtaskUser;
	int pageIndex;
	int pageSize;
	Date ed;
	Date sd;

	public String addTask() {

		int code = deBugTaskService.addDeBugTask(debugtask, dps);

		json = "{code:" + code + "}";

		return "success";

	}

	public String findWait() {

		json = MyJSON.toJson(deBugTaskService.findWait(),
				"circuitriesForStartpoleNo", "circuitriesForEndpoleNo")
				.toString();

		return "success";
	}

	public String findWaitByUid() {

		json = MyJSON.toJson(deBugTaskService.findWaitByUid(),
				"circuitriesForStartpoleNo", "circuitriesForEndpoleNo")
				.toString();

		return "success";
	}

	public String findExecuting() {

		json = MyJSON.toJson(deBugTaskService.findExecuting(),
				"circuitriesForStartpoleNo", "circuitriesForEndpoleNo")
				.toString();

		return "success";
	}

	public String findMissPass() {

		json = MyJSON.toJson(deBugTaskService.findAuditingMissPass(),
				"circuitriesForStartpoleNo", "circuitriesForEndpoleNo")
				.toString();

		return "success";

	}

	public String assignUser() {
		int code = deBugTaskService.assignUser(did, uid);
		json = "{code:" + code + "}";
		return "success";

	}

	public String executeTask() {
		int code = deBugTaskService.executeTask(did);
		json = "{code:" + code + "}";

		return "success";
	}

	public String statistics() {
		PageBean bean = deBugTaskService.statistics(debugtask, debugtaskUser,
				sd, ed, pageIndex, pageSize);
		json = MyJSON.toJson(bean, "circuitriesForStartpoleNo",
				"circuitriesForEndpoleNo").toString();
		return "success";
	}

	public String export() {
		String name = deBugTaskService.export(debugtask, debugtaskUser, sd, ed);
		json = "{\"file\" :\"" + name + "\"}";
		return "success";
	}

	public String getJson() {
		return json;
	}

	public void setJson(String json) {
		this.json = json;
	}

	public Debugtask getDebugtask() {
		return debugtask;
	}

	public void setDebugtask(Debugtask debugtask) {
		this.debugtask = debugtask;
	}

	public DeBugTaskService getDeBugTaskService() {
		return deBugTaskService;
	}

	public void setDeBugTaskService(DeBugTaskService deBugTaskService) {
		this.deBugTaskService = deBugTaskService;
	}

	public String getDps() {
		return dps;
	}

	public void setDps(String dps) {
		this.dps = dps;
	}

	public String getUid() {
		return uid;
	}

	public void setUid(String uid) {
		this.uid = uid;
	}

	public String getDid() {
		return did;
	}

	public void setDid(String did) {
		this.did = did;
	}

	public DebugtaskUser getDebugtaskUser() {
		return debugtaskUser;
	}

	public void setDebugtaskUser(DebugtaskUser debugtaskUser) {
		this.debugtaskUser = debugtaskUser;
	}

	public int getPageIndex() {
		return pageIndex;
	}

	public void setPageIndex(int pageIndex) {
		this.pageIndex = pageIndex;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public Date getEd() {
		return ed;
	}

	public void setEd(Date ed) {
		this.ed = ed;
	}

	public Date getSd() {
		return sd;
	}

	public void setSd(Date sd) {
		this.sd = sd;
	}

}
